<template>
  <div>
    <el-tabs v-model="activeName" type="border-card" @tab-click="tabClick">
      <el-tab-pane label="项目打包" name="package">
        <package ref="package" @unitInfo="unitInfo"></package>
      </el-tab-pane>
      <el-tab-pane label="单位信息" name="unit" :disabled="unitShow">
        <unit ref="unit" :switch="editSwitch" :unitId="unitId"></unit>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import Package from './package.vue'
import Unit from './unit'
export default {
  name: 'Pack',
  components: {
    Package,
    Unit

  },
  props: {

  },
  data () {
    return {
      activeName: 'package',
      unitId: '',
      unitShow: true,
      editSwitch: false
    }
  },
  created () {

  },
  mounted () {
  },
  methods: {
    init () {

    },
    tabClick (tab) {
      if (tab.name === 'package') {
        this.$refs.package.init()
      } else if (tab.name === 'unit') {
        this.$refs.unit.init()
      }
    },
    unitInfo (params) {
      this.unitId = params.id.toString()
      params.basket_status == "已同步" ? this.editSwitch = false : this.editSwitch = true
      setTimeout(() => {
        this.activeName = 'unit'
        this.$refs.unit.init()
        this.unitShow = false
      }, 500);
    }
  },
  computed: {

  }
}
</script>
<style lang='scss' scoped>
</style>
